package com.org.Bibliotech;

import org.junit.Test;

import java.util.ArrayList;

import static org.junit.Assert.*;

public class MyUnitTest {

    Book headFirstJava = new Book("Head First Java", "Kathy Sierra & Bert Bates", 2003);
    Book annaKarenina = new Book("Anna Karenina", "Leo Tolstoy", 1877);
    Book theJungle = new Book("The Jungle", "Upton Sinclair", 1906);

    ArrayList<Book> books = new ArrayList<Book>();



    Library library = new Library(books);




    @Test
    public void testCheckoutBook(){


        MyUnit myUnit = new MyUnit();
        books.add(headFirstJava);
        books.add(annaKarenina);

        Library library = new Library(books);

        String success = "Thank you! Enjoy the book";
        String fail = "That book is not available.";

        myUnit.createLibrary(library);
        assertEquals(success, myUnit.checkOut(headFirstJava) );
        assertEquals(fail, myUnit.checkOut(theJungle));


    }


    @Test
    public void testReturnBook(){


        MyUnit myUnit = new MyUnit();
        books.add(headFirstJava);
        books.add(annaKarenina);

        Library library = new Library(books);

        String success = "Thank you for returning the book.";
        String fail = "That is not a valid book to return.";

        myUnit.createLibrary(library);

     myUnit.checkOut(headFirstJava);

        assertEquals(fail, myUnit.returnBook(annaKarenina) );
        assertEquals(success, myUnit.returnBook(headFirstJava));


    }




}